<!DOCTYPE html>
<html>
<head>
    <%include("/back/_include/meta.html",{"title":""}){}%>
    <%include("/back/_include/style.html"){}%>
</head>
<body class="gray-bg">
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="row">
            <div class="col-sm-6">
                <form role="form" id="form">
                    <div class="form-group">
                        <label>名称</label>
                        <input type="text" id="name" name="name" class="form-control" required="" minlength="2" maxlength="20">
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 2~20个字符以内</span>
                    </div>
                    <div>
                        <button class="btn btn-sm btn-primary" id="save">
                            <strong>保存</strong>
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<%include("/back/_include/script.html"){}%>
<script src="/assets/ui/h+/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/assets/ui/h+/js/plugins/validate/messages_zh.min.js"></script>
<script>
    $.validator.setDefaults({
        submitHandler: function() {
            var name = $$('#name')
            post("/b/group/save",{"group.name":name},function (res) {
                if(!res.success){
                    error(res.msg)
                    return;
                }
                success("保存成功",false,function () {
                    window.location.reload();
                })
            },function () {
                systemErr();
            })
        }
    });
    $(function () {
        $("#form").validate({
            messages: {
                name: {required:"请输入名称", minlength:"名称必须2个字符以上",maxlength:"名称必须20个字符以下"},
            }
        })
    });
</script>
</body>
</html>